#include <iostream>
#include <string>
#include <math.h>
using namespace std;



int main(){
	int n,c,t=0,l,tf;
	cin>>n;
	int li[n]; 
	
	for(int i=0;i<n;i++){
	  cin>>li[i];
	}
	
	int minLi;
	int minIndex=0;
	for(int i=1;i<1000001;i=minLi){
		minLi = 1000001;
			c = 0;
			l = 0;
			tf = 0;
			int allZero=1;
			for(int j=minIndex;j<n;j++){
				if(li[j] == i+l){
					c = 1;
					li[j] = -1;
					//cout<<"li["<<j<<"] is killed by "<<i<<" when t="<<t<<endl; 
					l++;
				}
				if(li[j]!=-1 && li[j]<minLi){
					minLi = li[j];
				}
				if(li[j]!=-1 && allZero==1){
					minIndex = j;
					allZero = 0;
				}
				tf += li[j]!=-1?1:0;
			}
			minIndex = 0;
			if(c == 1){
				t++;
			}
		//cout<<"tf="<<tf<<" minLi="<<minLi<<endl;
		if(tf==1){
			 t++;
			 break;
		}
		if(tf == 0){
			break;
		}
	}
	
	cout<<t;
	
	return 0;
} 
